package com.bjsxt.web.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bjsxt.commons.DataGridModel;
import com.bjsxt.service.DrugService;

/**
 * 过期药品处理
 * @author  陈强
 */
@Controller
@RequestMapping("/overdueDrug")
public class OverdueDrugController {
	@Autowired
	private DrugService drugService;
	
	@RequestMapping("/dropOverdueDrug")
	@ResponseBody
	public Map<String, Integer>dropOverdueDrug(Integer drugid){
		Map<String, Integer>map=new HashMap<>(1);
		try {
			this.drugService.delOverdueDrug(drugid);
			map.put("state", 200);
			return map;
		} catch (Exception e) {
			map.put("state",500);
			return map;
		}
	}
	
	@RequestMapping("/showOverdueDrug")
	@ResponseBody
	public DataGridModel showProvider(@RequestParam(defaultValue="1") Integer page, @RequestParam(defaultValue="5") Integer rows){
		return this.drugService.findOverdueDrug(page,rows);
	}
}
